﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyPSDALayer;
using MyPS.Models;

namespace MyPS.Controllers
{
    public class ArticleController : Controller
    {
        MyPSEntities db = new MyPSEntities();
        //
        // GET: /Article/        
        public ActionResult Index()
        {
            ArticleModel mode = new ArticleModel();
            mode.ArticleTypeList = db.ArticleTypes.ToList();
            mode.ArticleList = db.Articles.Where(o => o.ISTop == "Y").Select(o => new Top_Article { ID = o.ArticleID, Name = o.ArticleName, CoverUrl = o.CoverUrl, Summary = o.Summary }).ToList();
            return View(mode);
        }

        public ActionResult ArticleDetail(int id)
        {
            ArticleDetailsModel mode = new ArticleDetailsModel();
            mode.ArticleTypeList = db.ArticleTypes.ToList();
            mode.Article = db.Articles.Find(id);              
            return View(mode);
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
